﻿<?php
require_once('../../config.php');
 require_once($CFG->libdir . '/adminlib.php');
 require_once($CFG->dirroot . '/local/myplugin/lib.php');
require_once($CFG->dirroot . "/local/myplugin/forms.php");


global $DB;


/* Ket noi den file javascript - module.js */
$PAGE->requires->js_init_call('M.local_myplugin');	
$cssdir =  $CFG->wwwroot.'/local/myplugin/css/mycss.css';
echo '<link rel="stylesheet" href="'.$cssdir.'" type="text/css" media="screen" />';
//echo '<link rel="stylesheet" href="style.css" type="text/css" media="screen" />';

/* Chuan bi trang web can hien thi */	
$url = new moodle_url($CFG->wwwroot.'local/myplugin/select_major.php');
$PAGE->set_url($url);
$PAGE->set_title('Select Major');
$PAGE->set_heading('Select Major');
$PAGE->set_pagelayout('standard');

//Them thanh menu ngang ung voi trang trong duong link
navigation_node::override_active_url(new moodle_url($CFG->wwwroot.'/local/myplugin/select_major.php', array('param'=>'value')));

echo $OUTPUT->header();

/* Viet doan code cua ban o day */
//add tab vào trang
$mylib = new curriculum_management();
//set tab hien tai 
$mylib ->view_tabs('addmajor');

$select_major_form = new form_choose_major();
//bat su kien nhan nu cancel
if ($select_major_form->is_cancelled()) {

echo 'hủy thao tác';

}

//kiem tra neu dc submitted thì làm gì
if ($fromform = $select_major_form->get_data()) 
{
	$program=$fromform->cbprogram;
	$cbchon=$_POST['cbchon'];
	foreach($cbchon as $item)
	{
		$option['major_id']=$item;
		$option['program_id']=$program;
		
		$mylib->add_program_major($option);
		
	}	
}

$select_major_form->display();
/*------Ket thuc doan code cua ban-------*/

echo $OUTPUT->footer();

